﻿//********************************************************************************//
//创建日期：<创建日期，2016-05-05>
//创建作者：<郭登杰，guodengjie@shanghai3h.com>
//功能说明：来涵用户基本信息
//********************************************************************************//

using System;
using System.Data;
using System.Web.UI;
using BLL;
using BLL.Access;
using DevExpress.Web;
using Entity;
using Web.Class;
using Web.Controls.LAIHAN;

namespace Web.Controls
{
    public partial class UCLHUserInfo : UserControl, IUCLHOperate
    {
        #region 属性

        /// <summary>
        ///     来函类型
        /// </summary>
        public eLaiHanLX LaiHanLX { get; set; }

        /// <summary>
        ///     当前流程
        /// </summary>
        public eLaiHanLCBH LaiHanLC { get; set; }

        public bool YVisiable
        {
            set
            {
                txtY.Visible = value;
                lblY.Visible = value;
            }
            get { return txtY.Visible; }
        }

        /// <summary>
        ///     控件月显示
        /// </summary>
        public bool MVisiable
        {
            set
            {
                txtM.Visible = value;
                lblM.Visible = value;
            }
            get { return txtM.Visible; }
        }

        /// <summary>
        ///     用户号
        /// </summary>
        public string YONGHUH
        {
            get { return hdCollection.Contains("yonghuh") ? hdCollection.Get("yonghuh").ToString() : ""; }
            set { hdCollection.Set("yonghuh", value); }
        }

        /// <summary>
        ///     当前文本框中的用户号
        /// </summary>
        public string YONGHUHINPUT
        {
            get { return txtYongHuH.Text; }
            set { txtYongHuH.Text = value; }
        }

        /// <summary>
        ///     获取当前文本框中用户号是否与查询出的用户号一致(此种情况应用于用户查询用户信息后又修改了用户号)
        /// </summary>
        public bool YONGHUHMATCH => YONGHUH == YONGHUHINPUT;

        /// <summary>
        ///     标识当前查询过的用户号是否存在
        /// </summary>
        public bool YONGHUHEXISTS => YONGHUH != "";

        /// <summary>
        ///     用户名
        /// </summary>
        public string YONGHUM
        {
            set { txtYongHuM.Text = value; }
            get { return txtYongHuM.Text; }
        }

        /// <summary>
        ///     地址
        /// </summary>
        public string DIZHI
        {
            set { txtDiZhi.Text = value; }
            get { return txtDiZhi.Text; }
        }

        /// <summary>
        ///     邮编
        /// </summary>
        public string YOUBIAN
        {
            set { txtYouBian.Text = value; }
            get { return txtYouBian.Text; }
        }

        /// <summary>
        ///     联系部门
        /// </summary>
        public string LIANXIBM
        {
            set { txtLianXiBM.Text = value; }
            get { return txtLianXiBM.Text; }
        }

        /// <summary>
        ///     来函编号
        /// </summary>
        public string LAIHANBH
        {
            set { txtLaiHanBH.Text = value; }
            get { return txtLaiHanBH.Text; }
        }

        /// <summary>
        ///     统一审批编码
        /// </summary>
        public string TONGYIBM
        {
            set { txtTongYiSPBH.Text = value; }
            get { return txtTongYiSPBH.Text; }
        }

        /// <summary>
        ///     许可受理编号
        /// </summary>
        public string XUKEBH
        {
            set { txtXuKeSLH.Text = value; }
            get { return txtXuKeSLH.Text; }
        }

        /// <summary>
        ///     联系人
        /// </summary>
        public string LIANXIR
        {
            set { txtLianXiR.Text = value; }
            get { return txtLianXiR.Text; }
        }

        /// <summary>
        ///     联系电话
        /// </summary>
        public string LIANXIDH
        {
            set { txtLianXiDH.Text = value; }
            get { return txtLianXiDH.Text; }
        }

        /// <summary>
        ///     联系手机
        /// </summary>
        public string LIANXISJ
        {
            set { txtLianXiSJ.Text = value; }
            get { return txtLianXiSJ.Text; }
        }

        /// <summary>
        ///     水量年
        /// </summary>
        public string Y
        {
            get { return hdCollection.Contains("Y") ? Convert.ToString(hdCollection.Get("Y")) : ""; }
            set
            {
                hdCollection.Set("Y", value);
                txtY.Text = value;
            }
        }
      
        /// <summary>
        ///     记忆上次查询的年
        /// </summary>
        private string YINPUT
        {
            set { txtY.Text = value; }
            get { return txtY.Text; }
        }

        /// <summary>
        ///     获取当前文本框中年是否与查询时的年一致)
        /// </summary>
        public bool YMATCH => YINPUT == Y;

        /// <summary>
        ///     水量月
        /// </summary>
        public string M
        {
            set { txtM.Text = value; }
            get { return txtM.Text; }
        }
    
        /// <summary>
        ///     站点
        /// </summary>
        public string ZHANDIANBH
        {
            get { return hdCollection.Contains("ZHANDIANBH") ? hdCollection.Get("ZHANDIANBH").ToString() : ""; }
            set { hdCollection.Set("ZHANDIANBH", value); }
        }

        /// <summary>
        ///     管理块号
        /// </summary>
        public string GUANLIKBH
        {
            get { return hdCollection.Contains("GUANLIKBH") ? hdCollection.Get("GUANLIKBH").ToString() : ""; }
            set { hdCollection.Set("GUANLIKBH", value); }
        }

        /// <summary>
        ///     判断引用页面类别   1月调整登记  2月调整修改  3其他页面调用 不可修改
        /// </summary>
        public int ControlType
        {
            get { return Convert.ToInt32(ViewState["ControlType"]); }
            set { ViewState["ControlType"] = value; }
        }

        /// <summary>
        ///     记录错误日志
        /// </summary>
        private string errorMsg
        {
            get { return Convert.ToString(ViewState["errorMsg"]); }
            set { ViewState["errorMsg"] = value; }
        }

        #endregion

        #region 变量

        #endregion

        #region 事件
        /// <summary>
        ///     加载事件
        /// </summary>
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack) InitControl();
        }

        /// <summary>
        ///     回调响应
        /// </summary>
        protected void ASPxCallback1_Callback(object source, CallbackEventArgs e)
        {
            var cr = new CallbackResult(e.Parameter);
            if (e.Parameter == "yonghuh") //响应用户号回车事件
            {
                LoadData(txtYongHuH.Text, cr);
            }
            else if (e.Parameter == "ym") //响应水量年回车事件
            {
                LoadYMData(cr);
            }
            e.Result = cr.ToString();
        }

        /// <summary>
        ///     前台验证后实际执行后台操作
        /// </summary>
        protected void btnActPerform_Click(object sender, EventArgs e)
        {
            // 定额计算
            btnDinge.Visible = false;
            if (LaiHanLX == eLaiHanLX.年度)
            {
                var drc = new YS_YG_YONGHUXXBLL().SelectYS_YG_YONGHUXXesDynamic(" I_LEIXING=0 and S_YONGHUH='" + txtYongHuH.Text + "' ", null);
                string sSsdx = drc.Rows[0]["S_SHESHUIDXDM"].ToString();
                if (sSsdx.Length >= 4) sSsdx = sSsdx.Substring(0, 3);
                if ("413" == sSsdx || "414" == sSsdx || "415" == sSsdx || "416" == sSsdx)
                {
                    btnDinge.Visible = true;
                    btnDinge.Text ="学校定额计算";
                }
                else if ("417" == sSsdx)
                {
                    btnDinge.Visible = true;
                    btnDinge.Text = "医院定额计算";
                }
                if ("406" == sSsdx || "407" == sSsdx)
                {
                    btnDinge.Visible = true;
                    btnDinge.Text = "宾馆定额计算";
                }
            }
            // 来函信息
            var laihanxx = new YS_LH_LAIHANXX();
            laihanxx.S_LAIHANBH = null;
            laihanxx.I_LAIHANLX = (int) LaiHanLX;
            laihanxx.I_LIUCHENGBH = (int) eLaiHanLCBH.未登记;
            laihanxx.S_YONGHUBH = txtYongHuH.Text;
            laihanxx.I_TZY = txtY.Visible ? (int?) int.Parse(txtY.Text) : null;
            Y = txtY.Visible ? txtY.Text : null;
            laihanxx.I_TZM = txtM.Visible ? (int?) int.Parse(txtM.Text) : null;
            laihanxx.I_Y = laihanxx.I_TZY;
            laihanxx.I_M = laihanxx.I_TZM;
            IUCLHOperate ucinfo = null;
            IUCLHOperate ucinfo2 = null;
            if (LaiHanLX == eLaiHanLX.年度 || LaiHanLX == eLaiHanLX.基建调整)
            {
                ucinfo = Parent.FindControl("UCLHShenQingXX") as IUCLHOperate;
            }
            else if (LaiHanLX == eLaiHanLX.月度)
            {
                ucinfo = Parent.FindControl("UCLHShenQingXX_YDTZ") as IUCLHOperate;
            }
            else if (LaiHanLX == eLaiHanLX.计划变更 || LaiHanLX == eLaiHanLX.表计因素注销)
            {
                ucinfo = Parent.FindControl("UCLHShenQingXX_JHBG") as IUCLHOperate;
            }
            else if (LaiHanLX == eLaiHanLX.计划指标注销)
            {
                ucinfo = Parent.FindControl("UCLHShenQingXX_JHZBZX") as IUCLHOperate;
            }
            else if (LaiHanLX == eLaiHanLX.销户 || LaiHanLX == eLaiHanLX.销表)
            {
                ucinfo = Parent.FindControl("UCLHShuiBiaoList") as IUCLHOperate;
            }
            else if (LaiHanLX == eLaiHanLX.退款)
            {
                ucinfo = Parent.FindControl("UCLHShenQingXX_TK") as IUCLHOperate;
            }
            else if (LaiHanLX == eLaiHanLX.水资源销户)
            {
                ucinfo = Parent.FindControl("UCLHJinListQSView") as IUCLHOperate;
                ucinfo2 = Parent.FindControl("UCLHShuiBiaoListView") as IUCLHOperate;
                //ucinfo2 = this.Parent.FindControl("UCLHJinListQS") as IUCLHOperate;
            }

            //加载申请信息
            ucinfo.LoadInfo(laihanxx);
            if (ucinfo2 != null) ucinfo2.LoadInfo(laihanxx);
            //材料信息
            ucinfo = Parent.FindControl("UCLHBtnBottom") as IUCLHOperate;
            if (ucinfo != null) ucinfo.LoadInfo(laihanxx);
        }

        #endregion

        #region 方法

        /// <summary>
        ///     配置控件
        /// </summary>
        public void InitControl()
        {
            //默认设置错误信息,防止用户不搜索直接提交
            errorMsg = "error";
            //年调整默认显示当前水量年
            if (LaiHanLX == eLaiHanLX.年度) Y = (BusinessTool.GetWaterYM() / 100).ToString();
            txtYongHuH.Focus();
        }

        /// <summary>
        ///     根据当前流程状态设置步骤显示
        /// </summary>
        private void SetDisplay()
        {
            //先隐藏所有
            lblXuKeSLH.Visible = false;
            txtXuKeSLH.Visible = false;
            lblTongYiSPBH.Visible = false;
            txtTongYiSPBH.Visible = false;
            lblY.Visible = false;
            txtY.Visible = false;
            lblM.Visible = false;
            txtM.Visible = false;
            //根据类型显示需要的
            if (LaiHanLX == eLaiHanLX.年度 || LaiHanLX == eLaiHanLX.分户 || LaiHanLX == eLaiHanLX.基建调整 ||
                LaiHanLX == eLaiHanLX.计划变更
                || LaiHanLX == eLaiHanLX.表计因素注销 || LaiHanLX == eLaiHanLX.计划指标注销
                || LaiHanLX == eLaiHanLX.月度 || LaiHanLX == eLaiHanLX.退款)
            {
                lblXuKeSLH.Visible = true;
                txtXuKeSLH.Visible = true;
                lblTongYiSPBH.Visible = true;
                txtTongYiSPBH.Visible = true;
                lblY.Visible = true;
                txtY.Visible = true;
                if (LaiHanLX == eLaiHanLX.计划变更 || LaiHanLX == eLaiHanLX.表计因素注销 || LaiHanLX == eLaiHanLX.计划指标注销 ||
                    LaiHanLX == eLaiHanLX.月度)
                {
                    lblM.Visible = true;
                    txtM.Visible = true;
                }
                else if (LaiHanLX == eLaiHanLX.退款)
                {
                    lblTongYiSPBH.Visible = false;
                    txtTongYiSPBH.Visible = false;
                    lblM.Visible = true;
                    txtM.Visible = true;
                }

                if (LaiHanLX == eLaiHanLX.月度)
                {
                    PageTools.SetDisabled(txtY, false);
                    PageTools.SetDisabled(txtM, false);
                }
            }

            if (LaiHanLX == eLaiHanLX.分户 || LaiHanLX == eLaiHanLX.改户)
            {
                lblM.Visible = false;
                txtM.Visible = false;

                lblY.Visible = false;
                txtY.Visible = false;
            }

            //受理之后不可编辑.下方switch中case 3可去除.使用此控件的受理之后的页面该控件属性需加上LaiHanLC="受理"
            if ((int) LaiHanLC == (int) eLaiHanLCBH.未登记)
            {
                txtLianXiSJ.ReadOnly = false;
                //txtM.ReadOnly = false;
                //txtY.ReadOnly = false;
                //txtYongHuH.ReadOnly = false;
                txtYongHuH.ClientEnabled = true;
                txtY.ClientEnabled = true;
                txtM.ClientEnabled = true;
                //PageTools.SetDisabled(txtYongHuH, false);
                //PageTools.SetDisabled(txtY, false);
                //PageTools.SetDisabled(txtM, false);
                txtYongHuM.ClientEnabled = true;
                txtYouBian.ClientEnabled = true;
                txtLianXiR.ClientEnabled = true;
                txtLianXiDH.ClientEnabled = true;
                txtLianXiBM.ClientEnabled = true;
                txtDiZhi.ClientEnabled = true;
            }
            else if ((int) LaiHanLC == (int) eLaiHanLCBH.预登记)
            {
                txtLianXiSJ.ReadOnly = false;
                //txtM.ReadOnly = true;
                //txtY.ReadOnly = true;
                //txtYongHuH.ReadOnly = true;
                //PageTools.SetDisabled(txtYongHuH, true);
                //PageTools.SetDisabled(txtY, true);
                //PageTools.SetDisabled(txtM, true);
                txtYongHuH.ClientEnabled = false;
                txtY.ClientEnabled = false;
                txtM.ClientEnabled = false;
                txtYongHuM.ClientEnabled = true;
                txtYouBian.ClientEnabled = true;
                txtLianXiR.ClientEnabled = true;
                txtLianXiDH.ClientEnabled = true;
                txtLianXiBM.ClientEnabled = true;
                txtDiZhi.ClientEnabled = true;
            }

            if ((int) LaiHanLC >= (int) eLaiHanLCBH.登记)
            {
                txtYongHuH.ClientEnabled = false;
                txtY.ClientEnabled = false;
                txtM.ClientEnabled = false;
                //PageTools.SetDisabled(txtYongHuH, true);
                //PageTools.SetDisabled(txtY, true);
                //PageTools.SetDisabled(txtM, true);
                //txtLianXiSJ.ReadOnly = true;
                //txtM.ReadOnly = true;
                //txtY.ReadOnly = true;
                //txtYongHuH.ReadOnly = true;
                txtYongHuM.ClientEnabled = false;
                txtYouBian.ClientEnabled = false;
                txtLianXiR.ClientEnabled = false;
                txtLianXiDH.ClientEnabled = false;
                txtLianXiBM.ClientEnabled = false;
                txtDiZhi.ClientEnabled = false;
            }

            switch (ControlType)
            {
                case 2:

                    txtY.ClientEnabled = false;
                    txtM.ClientEnabled = false;
                    txtYongHuH.ClientEnabled = false;
                    break;
                case 3:
                    //txtYongHuH.Attributes.Add("disabled", "disabled");
                    //txtY.Attributes.Add("disabled", "disabled");
                    //txtM.Attributes.Add("disabled", "disabled");
                    txtYongHuH.ClientEnabled = false;
                    txtY.ClientEnabled = false;
                    txtM.ClientEnabled = false;
                    txtLianXiSJ.ClientEnabled = false;
                    txtM.ClientEnabled = false;
                    txtY.ClientEnabled = false;
                    txtYongHuH.ClientEnabled = false;
                    txtYongHuM.ClientEnabled = false;
                    txtYouBian.ClientEnabled = false;
                    txtLianXiR.ClientEnabled = false;
                    txtLianXiDH.ClientEnabled = false;
                    txtLianXiBM.ClientEnabled = false;
                    txtDiZhi.ClientEnabled = false;
                    break;
            }
        }
   
        /// <summary>
        ///     验证数据
        /// </summary>
        public ValidateRS Validate()
        {
            var rs = new ValidateRS();
            if (LaiHanLC == eLaiHanLCBH.未登记)
            {
                //判断用户号是否存在
                if (txtYongHuH.Text == "")
                {
                    rs.Msg = "请输入用户号。";
                    return rs;
                }

                if (!YONGHUHMATCH)
                {
                    rs.Msg = "若您修改了用户号,请重新查询用户信息。";
                    return rs;
                }

                if (!YONGHUHEXISTS)
                {
                    rs.Msg = "请检查用户号正确性。若您修改了用户号,请重新查询用户信息。";
                    return rs;
                }

                if (txtY.Visible && txtY.Text == "")
                {
                    rs.Msg = "水量年不能为空。";
                    return rs;
                }

                int zhi;
                if (!int.TryParse(txtY.Text, out zhi))
                {
                    rs.Msg = "请输入正确的水量年。";
                    return rs;
                }

                if (!YMATCH)
                {
                    rs.Msg = "若您修改了水量年月,请重新查询信息。";
                    return rs;
                }

                if (LaiHanLX == eLaiHanLX.年度 || LaiHanLX == eLaiHanLX.月度)
                {
                    var ym = Convert.ToInt32(hdCollection.Get("ym"));
                    if (int.Parse(Y) < ym / 100)
                    {
                        rs.Msg = "无法对历史年月进行调整。";
                        return rs;
                    }

                    if (LaiHanLX == eLaiHanLX.月度)
                    {
                        if (txtM.Visible && txtM.Text == "")
                        {
                            rs.Msg = "水量月不能为空。";
                            return rs;
                        }

                        if (!int.TryParse(txtM.Text, out zhi))
                        {
                            rs.Msg = "请输入正确的水量月。";
                            return rs;
                        }
                    }
                }
            }
            else if (LaiHanLC <= eLaiHanLCBH.预登记)
            {
                int iSLYM = int.Parse(BLL.BusinessTool.YS_GETSETTINGSVALUE(eSETTINGS_KEYNAME.WATER_Y_M.ToString()));
                string month = txtM.Text;
                if (month.Length <= 1)
                {
                    month = "0" + month;
                }
                int jSLYM = Convert.ToInt32(Y + month);
                int zhi;
                if (LaiHanLX == eLaiHanLX.月度)
                {
                    if (txtM.Visible && txtM.Text == "")
                    {
                        rs.Msg = "水量月不能为空。";
                        return rs;
                    }
                    
                    if (!int.TryParse(txtM.Text, out zhi))
                    {
                        rs.Msg = "请输入正确的水量月。";
                        return rs;
                    }
                    //if(iSLYM!= jSLYM)
                    //{
                    //    rs.Msg = "水量年月不对。";
                    //    return rs;
                    //}
                }
                //计划变更 是否存在相同 用户号，水量年月 的 旧欠托收
                 if (LaiHanLX == eLaiHanLX.计划变更)
                {
                    SpHelper sh =new SpHelper ();
                    string err ;
                    string msg ;
                    int ym = Convert.ToInt32(Y + month);
                    string yonghuh = txtYongHuH.Text;
                    sh.YS_ZW_DateCheckJHBG(201809, yonghuh, out err, out msg);
                    if(err=="001" || err == "002")
                    {
                        rs.Msg = msg;
                        return rs;
                    }
                }
                if (txtYongHuM.Text == "")
                {
                    rs.Msg = "用户名不能为空。";
                    return rs;
                }

            }

            rs.IsSuccess = true;
            return rs;
        }

        /// <summary>
        ///     清除数据
        /// </summary>
        public void ClearInfo()
        {
            txtDiZhi.Text = "";
            txtLaiHanBH.Text = "";
            txtLianXiBM.Text = "";
            txtLianXiDH.Text = "";
            txtLianXiR.Text = "";
            txtLianXiSJ.Text = "";
            txtM.Text = "";
            txtTongYiSPBH.Text = "";
            txtXuKeSLH.Text = "";
            txtY.Text = "";
            txtYongHuH.Text = "";
            txtYongHuM.Text = "";
            txtYouBian.Text = "";
            YONGHUH = "";
        }

        /// <summary>
        ///     加载来涵用户信息
        /// </summary>
        /// <param name="yonghuh">登记时搜索用</param>
        public void LoadData(string yonghuh, CallbackResult cr)
        {
            DataRowCollection drc;
            var zhandian = BusinessTool.ZHANDIANBH();
            // 已销户的用户，仍可以进行计划指标注销等登记
            string sOther = " and I_JLZT=0 ";
            if (LaiHanLX == eLaiHanLX.计划指标注销)
            {
                sOther = "";
            }
            if ((int) LaiHanLX < 20)
                drc = new YS_YG_YONGHUXXBLL()
                    .SelectYS_YG_YONGHUXXesDynamic(
                        " I_LEIXING=0" + (zhandian == "00" ? "" : " AND S_ZHANDIANBH=" + zhandian) +
                        " and S_YONGHUH='" + yonghuh + "' " + sOther, null).Rows;
            else
                drc = new QS_YG_YONGHUXXBLL()
                    .SelectQS_YG_YONGHUXXesDynamic(
                        "I_JLZT=0 and S_YONGHUH='" + yonghuh + "' AND I_WTYPE=" + BusinessTool.WType, null).Rows;
            if (drc.Count == 0)
            {
                cr.Msg = "查询不到该用户信息。";
                cr.IsAlertMsg = true;
                cr.IsSuccess = false;
                return;
            }

            if (LaiHanLX == eLaiHanLX.销户)
                if (new YS_CB_YONGHUSBGXProcess()
                        .SelectYS_CB_YONGHUSBGXesDynamic("I_JLZT=0 AND S_YONGHUBH='" + yonghuh + "'", null).Rows.Count >
                    0)
                {
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    cr.Msg = "该用户还有未销的表,无法销户!";
                    return;
                }

            //if ((int)this.LaiHanLX <= 20 && this.LaiHanLX != eLaiHanLX.计划变更 && this.LaiHanLX != eLaiHanLX.退款)
            //{
            //    if (drc[0]["I_KAOHEFY"].ToString() != "1")
            //    {
            //        cr.Msg = "该用户不是考核用户,只能做计划变更和退款操作。";
            //        cr.IsAlertMsg = true;
            //        cr.IsSuccess = false;
            //        return;
            //    }
            //}
            var msg = "";
            if (LaiHanLCTools.HasRelationExists((int) LaiHanLX, null, txtYongHuH.Text, txtY.Text, txtM.Text, out msg))
            {
                cr.Msg = msg;
                cr.IsAlertMsg = true;
                cr.IsSuccess = false;
                return;
            }

            errorMsg = "";
            //用户已上传的材料对应的材料控件中材料位置
            var cls = "-1";
            var uccl = Page.FindControl("UCLHCaiLiaoInfo") as UCLHCaiLiaoInfo;
            if (uccl != null) cls = uccl.BindCheckBox(txtYongHuH.Text, null);
            if ((int) LaiHanLX < 20)
                cr.AddValue(drc[0]["S_YONGHUM"], drc[0]["S_DIZHI"], drc[0]["S_YOUBIAN"], drc[0]["S_LIANXIBM"],
                    drc[0]["S_LIANXIR"], drc[0]["S_LIANXIDH"]);
            else
                cr.AddValue(drc[0]["S_YONGHUM"], drc[0]["S_DIZHI"], drc[0]["S_YOUBIAN"], drc[0]["S_LIANXIBM"],
                    drc[0]["S_LIANXIR"], drc[0]["S_DIANHUA"]);
            //有材料 材料位置加在用户信息后一起返回
            if (cls != "-1") cr.AddValue(cls);
            cr.IsSuccess = true;
            cr.IsAlertMsg = false;
        }

        public void LoadData(string laihanbh)
        {
            DataRowCollection drc;
            //加载用户信息
            drc = new YS_LH_YONGHUXXProcess()
                .SelectYS_LH_YONGHUXXesDynamic(string.Format("S_LAIHANBH='{0}'", laihanbh), "", null).Rows;
            if (drc.Count == 1)
            {
                YONGHUH = drc[0]["S_YONGHUBH"].ToString();
                YONGHUHINPUT = drc[0]["S_YONGHUBH"].ToString();
                YONGHUM = drc[0]["S_YONGHUM"].ToString();
                DIZHI = drc[0]["S_DIZHI"].ToString();
                LIANXIBM = drc[0]["S_LIANXIBM"].ToString();
                YOUBIAN = drc[0]["S_YOUBIAN"].ToString();
                LIANXIR = drc[0]["S_LIANXIR"].ToString();
                LIANXIDH = drc[0]["S_LIANXIDH"].ToString();
            }
            else
            {
                YONGHUH = "";
                Y = "";
            }

            //加载许可号等信息
            drc = new YS_LH_LAIHANXXProcess().SelectYS_LH_LAIHANXXesDynamic("S_LAIHANBH='" + laihanbh + "'", null).Rows;
            if (drc.Count == 1)
            {
                XUKEBH = drc[0]["S_XUKEBH"].ToString();
                TONGYIBM = drc[0]["S_TONGYIBM"].ToString();
                LAIHANBH = drc[0]["S_LAIHANBH"].ToString();
                Y = drc[0]["I_Y"].ToString();
                M = Convert.ToString(drc[0]["I_M"].ToString());
                YINPUT = drc[0]["I_Y"].ToString();
                ZHANDIANBH = drc[0]["S_ZHANDIANBH"].ToString();
                GUANLIKBH = drc[0]["S_GUANLIKBH"].ToString();
            }
            else
            {
                YONGHUH = "";
                Y = "";
            }
        }

        /// <summary>
        ///     加载对应年月申请信息数据
        /// </summary>
        /// <returns></returns>
        private void LoadYMData(CallbackResult cr)
        {
            int? rsno = -1;
            var rsmsg = "";
            //不能调整历史年月
            var waterYM = BusinessTool.GetWaterYM();
            var ymT = -1;
            /*水量年月验证 start*/
            if (MVisiable)
                if (int.Parse(txtM.Text) < 1 || int.Parse(txtM.Text) > 12)
                {
                    cr.Msg = "请输入正确的月份。";
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }

            if (LaiHanLX == eLaiHanLX.年度)
            {
                if (int.Parse(txtY.Text) < waterYM / 100 || (int.Parse(txtY.Text) > waterYM / 100 && waterYM % 100 < 10))
                {
                    cr.Msg = "请输入正确的水量年。";
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }
            }
            else if (LaiHanLX == eLaiHanLX.基建调整)
            {
                if (waterYM % 100 != 12 && int.Parse(txtY.Text) != waterYM / 100 &&
                    int.Parse(txtY.Text) != waterYM / 100 + 1)
                {
                    cr.Msg = "请输入正确的水量年。";
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }

                if (waterYM % 100 == 12 && int.Parse(txtY.Text) != waterYM / 100 + 1)
                {
                    cr.Msg = "请输入正确的水量年。";
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }
            }
            else if (LaiHanLX == eLaiHanLX.计划变更)
            {
                ymT = int.Parse(txtY.Text) * 100 + int.Parse(txtM.Text);
                var ymStart = Convert.ToInt32(DateTime.Now.AddMonths(-5).ToString("yyyyMM"));
                var ymEnd = Convert.ToInt32(new DateTime(BusinessTool.GetZWYM() / 100, BusinessTool.GetZWYM() % 100, 1)
                    .AddMonths(-2).ToString("yyyyMM"));
                if (!(ymT >= ymStart && ymT <= ymEnd))
                {
                    cr.Msg = "计划变更的范围应为:" + ymStart + "~" + ymEnd + "！";
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }
            }
            //20190322 去掉年月限制,与计划指标注销相同
            //else if (LaiHanLX == eLaiHanLX.表计因素注销)
            //{
            //    if (!(int.Parse(txtY.Text) * 100 + int.Parse(txtM.Text) <=
            //          Convert.ToInt32(DateTime.Now.AddMonths(-3).ToString("yyyyMM"))))
            //    {
            //        cr.Msg = "表计因素注销范围应为:" + Convert.ToInt32(DateTime.Now.AddMonths(-3).ToString("yyyyMM")) + "之前（包含" + Convert.ToInt32(DateTime.Now.AddMonths(-3).ToString("yyyyMM")) + "）";
            //        cr.IsSuccess = false;
            //        cr.IsAlertMsg = true;
            //        return;
            //    }
            //}
            else if (LaiHanLX == eLaiHanLX.计划指标注销 || LaiHanLX == eLaiHanLX.表计因素注销)
            {
                if (int.Parse(txtY.Text) * 100 + int.Parse(txtM.Text) > waterYM)
                {
                    cr.Msg = "请输入正确的水量年月。";
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }
            }
            /*水量年月验证 end*/

            /*计划信息验证 start*/
            if (LaiHanLX == eLaiHanLX.年度 && int.Parse(txtY.Text) > waterYM / 100)
            {
                var drc = new YS_JH_QUEDINGJHBLL().SelectYS_JH_QUEDINGJHsDynamic(string.Format(" I_JLZT=0 AND I_TYPE=3 AND S_YONGHUH='{0}'", YONGHUH), null).Rows;

                if (drc.Count == 0)
                {
                    cr.Msg = "查询不到该用户对应计划信息。";
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }
            }
            else if (LaiHanLX == eLaiHanLX.年度 || LaiHanLX == eLaiHanLX.基建调整 || LaiHanLX == eLaiHanLX.月度)
            {
                var drc = new YS_JH_YUANJIHUAProcess()
                    .SelectYS_JH_YUANJIHUAsDynamic(
                        "S_YONGHUH='" + YONGHUH + "' AND I_Y=" + Convert.ToInt32(YINPUT) + " AND I_JLZT=0", null).Rows;
                if (drc.Count == 0)
                {
                    cr.Msg = "查询不到该用户对应计划信息。";
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }

                //int? syl, yjh;                
                //DataSet ds = new SpHelper().P_YS_LH_YONGHUYSSJCX(Convert.ToInt32(this.YINPUT),(int.Parse(this.txtM.Text)), this.YONGHUH, out yjh, out syl);
                //判断对应用户是否有计划信息
                /*
                if (this.LaiHanLX == eLaiHanLX.年度 || this.LaiHanLX == eLaiHanLX.基建调整)
                {
                    if (ds.Tables[1] == null || ds.Tables[1].Rows.Count == 0)
                    {
                        cr.Msg = "查询不到该用户计划信息。";
                        cr.IsSuccess = false;
                        cr.IsAlertMsg = true;
                        return;
                    }
                    else
                    {
                        yuanjihHas = true;
                    }
                }
                else if (this.LaiHanLX == eLaiHanLX.月度)
                {
                    if (yjh == 0)
                    {
                        cr.Msg = "查询不到该用户对应月度计划信息。";
                        cr.IsSuccess = false;
                        cr.IsAlertMsg = true;
                        return;
                    }
                }
            */
            }
            /*计划信息验证 end*/

            /*逻辑验证 start*/
            DataRowCollection drcYSSJ = null;
            DataRowCollection drcYYZ = null;
            if (LaiHanLX == eLaiHanLX.计划变更 || LaiHanLX == eLaiHanLX.表计因素注销)
            {
                ymT = int.Parse(txtY.Text) * 100 + int.Parse(txtM.Text);
                var dt = new YS_JH_YONGHUYSSJProcess().SelectYS_JH_YONGHUYSSJsDynamic(
                    "I_Y=" + txtY.Text + " AND I_M=" + txtM.Text + " AND S_YONGHUH='" + YONGHUH + "'", null);
                //获取实用量,计划量等
                //drcYSSJ = new SpHelper().P_YS_LH_YONGHUYSSJCX(int.Parse(this.txtY.Text), int.Parse(this.txtM.Text), this.YONGHUH, null).Tables[0].Rows;
                //获取对应年月营业账信息
                drcYYZ = new YS_ZW_YINGYEZBLL()
                    .SelectYS_ZW_YINGYEZsDynamic(
                        "I_JLZT=0 and S_YONGHUH='" + YONGHUH + "' and I_Y=" + txtY.Text + " and I_M=" + txtM.Text, null)
                    .Rows;
                if (dt.Rows.Count == 0)
                {
                    cr.Msg = "该用户该年月暂无用水数据。";
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }

                /*
            else if (drcYSSJ.Count > 1)
            {
                cr.Msg = "该用户该年月用水数据重复,请检查。";
                cr.IsSuccess = false;
                cr.IsAlertMsg = true;
                return;
            }*/
                if (drcYYZ.Count == 0)
                {
                    cr.Msg = "该用户对应年月未开账。";
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }

                if (Convert.ToDecimal(drcYYZ[0]["N_JIAJIAJE"]) == 0)
                {
                    cr.Msg = "该用户对应年月无加价账单。";
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }

                if (LaiHanLX == eLaiHanLX.计划变更 || LaiHanLX == eLaiHanLX.表计因素注销)
                    if (Convert.ToDecimal(drcYYZ[0]["N_YINGSHOUJE"]) <= Convert.ToDecimal(drcYYZ[0]["N_SHISHOUJE"]))
                    {
                        cr.Msg = "该用户对应年月未欠费。";
                        cr.IsSuccess = false;
                        cr.IsAlertMsg = true;
                        return;
                    }
            }
            else if (LaiHanLX == eLaiHanLX.退款)
            {
                ymT = int.Parse(txtY.Text) * 100 + int.Parse(txtM.Text);
                new SpHelper().P_YSLH_TUIKUANXXHQ(null, YONGHUH, ymT, 1, out rsno, out rsmsg);
                if (rsno != 1)
                {
                    cr.Msg = rsmsg;
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }
            }
            else if (LaiHanLX == eLaiHanLX.计划指标注销)
            {
                ymT = int.Parse(txtY.Text) * 100 + int.Parse(txtM.Text);
                drcYYZ = new YS_ZW_YINGYEZBLL()
                    .SelectYS_ZW_YINGYEZsDynamic(
                        "I_JLZT=0 and S_YONGHUH='" + YONGHUH + "' and N_YINGSHOUJE>N_SHISHOUJE and I_Y*100+I_M<=" + ymT,
                        null).Rows;
                if (drcYYZ.Count == 0)
                {
                    cr.Msg = "没有需要注销的指标。";
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }
            }
            //判断用户是否已经存在指定年月未到账的托收,如果存在则不允许登记来函 添加 20190322
            if (LaiHanLX == eLaiHanLX.计划变更 || LaiHanLX == eLaiHanLX.表计因素注销 || LaiHanLX == eLaiHanLX.计划指标注销)
            {
                ymT = int.Parse(txtY.Text) * 100 + int.Parse(txtM.Text);
                DataRowCollection drcTS = new SpHelper().P_LH_HASTUOSHOUYM((int)LaiHanLX, YONGHUH, ymT).Tables[0].Rows;
                if (drcTS.Count > 0)
                {
                    cr.Msg = "该用户该年月有未到账的托收";
                    if (LaiHanLX == eLaiHanLX.计划指标注销)
                    {
                        cr.Msg = "该用户该年月为止有未到账的托收";
                    }
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }
            }
            /*逻辑验证 end*/

            //按当前年月重新加载用户名
            if ((int) LaiHanLX <= 20 && YVisiable)
            {
                var ymtemp = txtY.Text != "" && txtM.Text != "" ? int.Parse(txtY.Text) * 100 + int.Parse(txtM.Text) :
                    txtY.Text != "" && txtM.Text == "" ? int.Parse(txtY.Text) :
                    0;
                var yonghum = "";
                new SpHelper().P_COMMON_HUOQULSYHM(txtYongHuH.Text, ymtemp == 0 ? null : (int?) ymtemp, out yonghum,
                    out rsno, out rsmsg);
                if (rsno != 1)
                {
                    cr.Msg = rsmsg;
                    cr.IsSuccess = false;
                    cr.IsAlertMsg = true;
                    return;
                }

                cr.SpecialIndetity = yonghum;
            }

            cr.IsSuccess = true;
            cr.IsAlertMsg = false;
        }

        /// <summary>
        ///     根据来函加载信息
        /// </summary>
        public void LoadInfo(YS_LH_LAIHANXX laihanxx)
        {
            //登记前
            if (laihanxx.ID == 0)
            {
                LaiHanLC = eLaiHanLCBH.未登记;
                SetDisplay();
                return;
            }

            LaiHanLC = (eLaiHanLCBH) Enum.Parse(typeof(eLaiHanLCBH), laihanxx.I_LIUCHENGBH.ToString());
            SetDisplay();
            //加载许可号等信息
            XUKEBH = laihanxx.S_XUKEBH;
            TONGYIBM = laihanxx.S_TONGYIBM;
            LAIHANBH = laihanxx.S_LAIHANBH;
            if (LaiHanLX == eLaiHanLX.月度 || LaiHanLX == eLaiHanLX.年度 || LaiHanLX == eLaiHanLX.基建调整 || LaiHanLX == eLaiHanLX.计划变更
                 || LaiHanLX == eLaiHanLX.退款)
            {
                txtY.Text = Convert.ToString(laihanxx.I_TZY);
                txtM.Text = Convert.ToString(laihanxx.I_TZM);
            }
            else
            {
                txtY.Text = Convert.ToString(laihanxx.I_Y);
                txtM.Text = Convert.ToString(laihanxx.I_M);
            }

            Y = txtY.Text;
            M = txtM.Text;
            ZHANDIANBH = laihanxx.S_ZHANDIANBH;
            GUANLIKBH = laihanxx.S_GUANLIKBH;
            //加载用户信息
            DataRowCollection drc = null;
            if (LaiHanLX == eLaiHanLX.分户 || LaiHanLX == eLaiHanLX.改户)
            {
                drc = new YS_YG_YONGHUXXProcess()
                    .SelectYS_YG_YONGHUXXesDynamic(string.Format("S_YongHuH='{0}'", laihanxx.S_YONGHUBH), "", null)
                    .Rows;
                if (drc.Count > 0)
                {
                    var id = 0;
                    foreach (DataRow row in drc)
                        if (Convert.ToInt32(row["ID"]) > id)
                        {
                            id = Convert.ToInt32(row["ID"]);
                            YONGHUH = row["S_YONGHUH"].ToString();
                            YONGHUHINPUT = row["S_YONGHUH"].ToString();
                            YONGHUM = row["S_YONGHUM"].ToString();
                            DIZHI = row["S_DIZHI"].ToString();
                            LIANXIBM = row["S_LIANXIBM"].ToString();
                            YOUBIAN = row["S_YOUBIAN"].ToString();
                            LIANXIR = row["S_LIANXIR"].ToString();
                            LIANXIDH = row["S_LIANXIDH"].ToString();
                        }
                }
            }
            else if (LaiHanLX == eLaiHanLX.并户)
            {
                drc = new YS_LH_YONGHUTZProcess()
                    .SelectYS_LH_YONGHUTZsDynamic(
                        string.Format("S_LAIHANBH='{0}' and I_YUANYONGH=1", laihanxx.S_LAIHANBH), "", null).Rows;
                if (drc.Count == 1)
                {
                    YONGHUH = drc[0]["S_YONGHUH"].ToString();
                    YONGHUHINPUT = drc[0]["S_YONGHUH"].ToString();
                    YONGHUM = drc[0]["S_YONGHUM"].ToString();
                    DIZHI = drc[0]["S_DIZHI"].ToString();
                    LIANXIBM = drc[0]["S_LIANXIBM"].ToString();
                    YOUBIAN = drc[0]["S_YOUBIAN"].ToString();
                    LIANXIR = drc[0]["S_LIANXIR"].ToString();
                    LIANXIDH = drc[0]["S_LIANXIDH"].ToString();
                }
            }
            else if (LaiHanLX == eLaiHanLX.月度 || LaiHanLX == eLaiHanLX.年度)
            {
                drc = new YS_LH_YONGHUXXProcess()
                    .SelectYS_LH_YONGHUXXesDynamic(string.Format("S_LAIHANBH='{0}'", laihanxx.S_LAIHANBH), "", null)
                    .Rows;
                if (drc.Count > 0)
                {
                    var id = 0;
                    foreach (DataRow row in drc)
                        if (Convert.ToInt32(row["ID"]) > id)
                        {
                            id = Convert.ToInt32(row["ID"]);
                            YONGHUH = row["S_YONGHUBH"].ToString();
                            YONGHUHINPUT = row["S_YONGHUBH"].ToString();
                            YONGHUM = row["S_YONGHUM"].ToString();
                            DIZHI = row["S_DIZHI"].ToString();
                            LIANXIBM = row["S_LIANXIBM"].ToString();
                            YOUBIAN = row["S_YOUBIAN"].ToString();
                            LIANXIR = row["S_LIANXIR"].ToString();
                            LIANXIDH = row["S_LIANXIDH"].ToString();
                        }
                }
                else
                {
                    drc = new YS_YG_YONGHUXXProcess()
                        .SelectYS_YG_YONGHUXXesDynamic(string.Format("S_YongHuH='{0}'", laihanxx.S_YONGHUBH), "", null)
                        .Rows;
                    if (drc.Count > 0)
                    {
                        var id = 0;
                        foreach (DataRow row in drc)
                            if (Convert.ToInt32(row["ID"]) > id)
                            {
                                id = Convert.ToInt32(row["ID"]);
                                YONGHUH = row["S_YONGHUH"].ToString();
                                YONGHUHINPUT = row["S_YONGHUH"].ToString();
                                YONGHUM = row["S_YONGHUM"].ToString();
                                DIZHI = row["S_DIZHI"].ToString();
                                LIANXIBM = row["S_LIANXIBM"].ToString();
                                YOUBIAN = row["S_YOUBIAN"].ToString();
                                LIANXIR = row["S_LIANXIR"].ToString();
                                LIANXIDH = row["S_LIANXIDH"].ToString();
                            }
                    }
                }
            }
            else if (LaiHanLX == eLaiHanLX.水资源销户)
            {
                drc = new QS_YG_YONGHUXXProcess()
                    .SelectQS_YG_YONGHUXXesDynamic(string.Format("S_YONGHUH='{0}'", laihanxx.S_YONGHUBH), "", null)
                    .Rows;
                if (drc.Count == 1)
                {
                    YONGHUH = drc[0]["S_YONGHUH"].ToString();
                    YONGHUHINPUT = drc[0]["S_YONGHUH"].ToString();
                    YONGHUM = drc[0]["S_YONGHUM"].ToString();
                    DIZHI = drc[0]["S_DIZHI"].ToString();
                    LIANXIBM = drc[0]["S_LIANXIBM"].ToString();
                    YOUBIAN = drc[0]["S_YOUBIAN"].ToString();
                    LIANXIR = drc[0]["S_LIANXIR"].ToString();
                    LIANXIDH = drc[0]["S_DIANHUA"].ToString();
                }
            }
            else
            {
                drc = new YS_LH_YONGHUXXProcess()
                    .SelectYS_LH_YONGHUXXesDynamic(string.Format("S_LAIHANBH='{0}'", laihanxx.S_LAIHANBH), "", null)
                    .Rows;
                if (drc.Count > 0)
                {
                    var id = 0;
                    foreach (DataRow row in drc)
                        if (Convert.ToInt32(row["ID"]) > id)
                        {
                            id = Convert.ToInt32(row["ID"]);
                            YONGHUH = row["S_YONGHUBH"].ToString();
                            YONGHUHINPUT = row["S_YONGHUBH"].ToString();
                            YONGHUM = row["S_YONGHUM"].ToString();
                            DIZHI = row["S_DIZHI"].ToString();
                            LIANXIBM = row["S_LIANXIBM"].ToString();
                            YOUBIAN = row["S_YOUBIAN"].ToString();
                            LIANXIR = row["S_LIANXIR"].ToString();
                            LIANXIDH = row["S_LIANXIDH"].ToString();
                        }
                }
                else
                {
                    YONGHUH = "";
                }
            }
        }

        /// <summary>
        ///     获取来函主表信息
        /// </summary>
        /// <param name="laihanid">ID</param>
        /// <param name="liuchengzt">0:收件 1:收件并登记</param>
        /// <param name="msg">输出消息,正常为空</param>
        /// <returns>null:验证失败 !null:成功返回</returns>
        public YS_LH_LAIHANXX GetLAIHANXX(int laihanid, int liuchengzt, out string msg)
        {
            var laihan = new YS_LH_LAIHANXX();
            var laihanbh = "";
            var xukebh = "";
            msg = "";
            laihan.ID = laihanid;
            if (laihanid == 0)
            {
                string zd, glk, ywy;
                PageTools.GetLHDJZDGLKYWY(YONGHUH, out zd, out glk, out ywy);
                laihan.S_ZHANDIANBH = zd;
                laihan.S_GUANLIKBH = glk;
                laihan.I_YWY = int.Parse(ywy);
                laihan.S_YWY = BusinessTool.GetYWYName(ywy);
                //laihan.S_YHYWY = ywy;
                var numset = new SpHelper().P_YS_LH_XUKEBH(glk, (int) LaiHanLX, 0,
                    (BusinessTool.GetWaterYM() / 100).ToString(), out xukebh, out laihanbh);
                if (BusinessTool.WType != 0)
                    new SpHelper().P_ALL_LH_BHSC(BusinessTool.WType, (int) LaiHanLX, BusinessTool.GetWaterYM() / 100,
                        out laihanbh);
                laihan.I_XT = BusinessTool.WType;
                laihan.D_SHURURQ = DateTime.Now;
                laihan.D_LAIHANRQ = DateTime.Now;
                laihan.I_JLZT = 0;
                laihan.I_LAIHANLX = (int) LaiHanLX;
                laihan.I_SHURUR = LoginInfo.CurrentUser.UserID;
                laihan.I_AUTOTYPE = 0;
                laihan.S_LAIHANBH = laihanbh;
                laihan.S_BEIYONG1 = xukebh;
                laihan.S_XUKEBH = xukebh;
                laihan.I_LIUCHENGZT = (int) eLaiHanLCZT.流程中;

                //if (BusinessTool.WType == 0)
                //{
                //    laihan.I_Y = !string.IsNullOrEmpty(this.Y) ? decimal.Parse(this.Y) : (BusinessTool.GetWaterYM() / 100);
                //    laihan.I_M = this.M == "" ? (decimal?)null : Convert.ToDecimal(this.M);
                //}
                //else
                //{ 
                laihan.I_Y = BusinessTool.GetWaterYM() / 100;
                laihan.I_M = BusinessTool.GetWaterYM() % 100;
                //}
                if (LaiHanLX == eLaiHanLX.月度 || LaiHanLX == eLaiHanLX.年度 || LaiHanLX == eLaiHanLX.基建调整 || LaiHanLX == eLaiHanLX.计划变更
                    || LaiHanLX == eLaiHanLX.退款 || LaiHanLX == eLaiHanLX.表计因素注销 || LaiHanLX == eLaiHanLX.计划指标注销)
                {
                    if (!string.IsNullOrEmpty(txtY.Text)) laihan.I_TZY = decimal.Parse(txtY.Text);
                    if (!string.IsNullOrEmpty(txtM.Text)) laihan.I_TZM = decimal.Parse(txtM.Text);
                }

                // todo: 统一操作年月和调整年月（2018-08-24 by zzj）
                if (LaiHanLX == eLaiHanLX.月度 || LaiHanLX == eLaiHanLX.年度 || LaiHanLX == eLaiHanLX.基建调整 || LaiHanLX == eLaiHanLX.计划变更
                    || LaiHanLX == eLaiHanLX.退款 || LaiHanLX == eLaiHanLX.表计因素注销 || LaiHanLX == eLaiHanLX.计划指标注销)
                {
                    laihan.I_Y = laihan.I_TZY;
                    laihan.I_M = laihan.I_TZM;
                }

                laihan.S_TONGYIBM = TONGYIBM; //统一审批编码
                laihan.S_YONGHUBH = YONGHUH;
                laihan.S_YONGHUM = YONGHUM;
            }
            else
            {
                laihan = new YS_LH_LAIHANXXProcess().SelectYS_LH_LAIHANXX(laihan.ID);
            }

            laihan.I_LIUCHENGBH = liuchengzt;
            laihan.S_CAOZUOR = LoginInfo.CurrentUser.UserID.ToString();
            laihan.D_CAOZUOSJ = BusinessTool.GetDataBaseDateTime();
            return laihan;
        }

        /// <summary>
        ///     获取来函用户信息
        /// </summary>
        /// <param name="laihan"></param>
        /// <returns></returns>
        public YS_LH_YONGHUXX GetLHYONGHUXX(YS_LH_LAIHANXX laihan)
        {
            var lhyhxx = new YS_LH_YONGHUXX();
            lhyhxx.ID = 0;
            var oldyh = new YS_LH_YONGHUXXProcess().SelectYS_LH_YONGHUXXesDynamic(
                string.Format(" I_JLZT=0 and S_LAIHANBH='{0}'", laihan.S_LAIHANBH), "", null);
            if (oldyh != null && oldyh.Rows.Count > 0) lhyhxx.ID = Convert.ToInt32(oldyh.Rows[0]["ID"]);
            lhyhxx.D_XIUGAIRQ = DateTime.Now;
            lhyhxx.S_DIZHI = DIZHI;
            lhyhxx.S_LAIHANBH = laihan.S_LAIHANBH;
            lhyhxx.S_LIANXIBM = LIANXIBM;
            lhyhxx.S_LIANXIDH = LIANXIDH + " " + LIANXISJ;
            lhyhxx.S_LIANXIR = LIANXIR;
            lhyhxx.S_YONGHUBH = laihan.S_YONGHUBH;
            lhyhxx.S_YONGHUM = YONGHUM;
            lhyhxx.S_YOUBIAN = YOUBIAN;
            return lhyhxx;
        }

        public void KuaiJieDJ(string yonghuh)
        {
            var dt = new YS_YG_YONGHUXXBLL().SelectYS_YG_YONGHUXXesDynamic(
                "I_JLZT=0 AND I_LEIXING=0  and S_YONGHUH='" + yonghuh + "'", null);
            if (dt != null && dt.Rows.Count > 0)
            {
                var row = dt.Rows[0];
                YONGHUH = row["S_YONGHUH"].ToString();
                YONGHUHINPUT = row["S_YONGHUH"].ToString();
                YONGHUM = row["S_YONGHUM"].ToString();
                DIZHI = row["S_DIZHI"].ToString();
                LIANXIBM = row["S_LIANXIBM"].ToString();
                YOUBIAN = row["S_YOUBIAN"].ToString();
                LIANXIR = row["S_LIANXIR"].ToString();
                LIANXIDH = row["S_LIANXIDH"].ToString();
                ZHANDIANBH = row["S_ZHANDIANBH"].ToString();
                GUANLIKBH = row["S_GUANLIKBH"].ToString();

                PageTools.SetDisabled(txtYongHuH, true);
                PageTools.SetDisabled(txtY, true);
                PageTools.SetDisabled(txtM, true);
            }
        }

        #endregion
    }
}